<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">

<title>{$shmc}-快速付款</title>
   <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<link rel="stylesheet" href="__PUBLIC__/Css/pay.css?id=6" /> 

   
<script language="javascript">
 function getorder(){
       var id ={$id};
     $.ajax({
                type: "POST",
                url: "__CONTROLLER__/getorder2",
           
                cache: false,
               async:false,
                data: {
                    id:id
                },
                
         
                    success: function(data) {
$('#orderid').val(data);

        }
        });
   
    }
    function zf(){
            getorder();
        var price=$('#price').val();
        if(price <0.01){
         alert('金额不能小于0.01元');   
         $('#price').focus();   
        }else{
        $("#submit").removeClass("submit");
        $("#submit").addClass("submita");
        $('#submit').attr('onclick','()');
        $('#submit').val('正在处理中...');
     $.ajax({
                type: "POST",
                url: "__CONTROLLER__/pay2/id/{$id}",
           
                cache: false,
                dataType: "json",
                async:false,
                data: $('#tab').serialize(),
         
                    success: function(data) {
                        if(data===1){
                   alert('网络超时请重新支付');         
                                    getorder();    
        $("#submit").removeClass("submita");
        $("#submit").addClass("submit");
        $('#submit').attr('onclick','zf()');
        $('#submit').val('重新支付');               
                            
                        }else{
         onBridgeReady(data);}

        }
        });
   
    }}

function onBridgeReady(data){
	WeixinJSBridge.invoke(
		'getBrandWCPayRequest',
        data ,
		function(res){
			WeixinJSBridge.log(res.err_msg);
			if(res.err_msg==='get_brand_wcpay_request:ok')
			{
                            
                     paysuccess();
			
			} else{
                      getorder();    
        $("#submit").removeClass("submita");
        $("#submit").addClass("submit");
        $('#submit').attr('onclick','zf()');
        $('#submit').val('重新支付'); 
                            
                        }
			
		});
}

  function paysuccess(){
 var ordid = $('#orderid').val();
     $.ajax({
                type: "POST",
                url: "__CONTROLLER__/payover/id/{$id}/orderid/"+ordid,
           
                cache: false,
                dataType: "json",
                 async:false,
                data:{},
         
                    success: function(data) {
  if(data===0){
      
      window.location.replace("__CONTROLLER__/orderinfo/id/{$id}/orderid/"+ordid);
              }else{
      
      alert('支付失败');
                   }
        ////
               }
              
                       
     
  });
   
    }
</script>
</head>
<body>
 
<div class="zt">
<div class="zw"></div>
<div style="width: 100%;text-align: center">
<div class="logo"><img src="{$headimg}"></div>
</div>
<div class="zw"></div>
    <div class="cardexplain">
    
	<ul class="round">
	
		<li class="nob">
			<table>

	     <tr><td><form role="form" id="tab">
   <div class="form-group">
       <span>金额(元)</span>
       <label for="name"><span class="span">￥</span></label>
      <input type="number" class="form-control" id="price" name="price" >
   <input type="hidden" name="openid" id="openid" value="{$openid}"/>
   <input type="hidden" name="orderid" id="orderid" value=""/>
   </div>
                                                </form><td></tr>
					</table>
	
			
		</ul>
</div>

	
	
<div id="payDom"class="cardexplain">
	<div class="footReturn"style="text-align:center">
		<input type="button" onclick="zf()" class="submit" id="submit" value="微信支付"/>
               
	</div>
</div>
<div class="foots"><span>支付完成后，如需退款请及时联系店员</span></div>
<div class="footer">
    
    <span>华意科技提供技术支持</span>   
</div>
<div style="clean:both"></div>
</div>
</body>
</html>